package com.weetop.akly.presenter;

import android.app.Activity;

import com.weetop.akly.base.mvp.BaseModel;
import com.weetop.akly.base.mvp.BaseObserver;
import com.weetop.akly.base.mvp.BasePresenter;
import com.weetop.akly.bean.ApproveItem;
import com.weetop.akly.bean.BaseCountBean;
import com.weetop.akly.bean.MsgBean;
import com.weetop.akly.bean.SignRecordBean;
import com.weetop.akly.view.SignRecordView;
import com.weetop.akly.view.SpRecordView;

import java.util.ArrayList;
import java.util.Map;

public class SpRecordPresent extends BasePresenter<SpRecordView> {
    public SpRecordPresent(SpRecordView baseView, Activity activity) {
        super(baseView, activity);
    }

    /**
     * 获取消息列表
     */
    public void getSpRecord(String page,String keywords) {
        Map<String, String> params = myApplication.getGlobalData();
        // model_id  1:补卡申请	2:请假申请	3:外出申请	4:外勤申请
        params.put("model_id", "0");
        params.put("page", page);
        params.put("keywords", keywords);
        addDisposable(apiServer.getApproveList(params), new BaseObserver<BaseModel<BaseCountBean<ApproveItem>>>(baseView) {
            @Override
            public void onSuccess(BaseModel<BaseCountBean<ApproveItem>> o) {
//                baseView.getSpRecordSuccess(o.getda);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }
    /**
     * 获取消息列表
     */
    public void getSpRecord(String page) {
        Map<String, String> params = myApplication.getGlobalData();
        // 模板种类：0打卡，1审批，2到期，3订单
        params.put("model_type", "1");
        params.put("page", page);
        addDisposable(apiServer.getSignRecoed(params), new BaseObserver<BaseModel<SignRecordBean>>(baseView) {
            @Override
            public void onSuccess(BaseModel<SignRecordBean> o) {
                baseView.getSpRecordSuccess(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }

}
